import { createApp } from 'vue'
import App from './App.vue'
import 'normalize.css'
import '@/assets/css/index.less'
import router from './router'
import pinia from './store'
import registericons from '@/global/register-icons'
import { localCache } from './utils/cache'
import { mapMenusToRoutes } from './utils/map-menus'

// 实例化时重新添加动态路由
const menuData = localCache.getCache('routes')
if (menuData) {
  const routes = mapMenusToRoutes(menuData)
  if (routes && routes.length > 0) {
    routes.forEach((route) => {
      router.addRoute('Main', route)
    })
  }
}

const app = createApp(App)
app.use(registericons)
app.use(router)
app.use(pinia)
app.mount('#app')
